/*
 *
 * (c) Copyright Ascensio System Limited 2010-2023
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/


var VideoSaver = new function () {
    this.Init = function () {

        if (jq("#dropVideoList li a").length != 0) {
            jq(".menu-list .video-guides").find(".new-label-menu").text(jq("#dropVideoList li a").length).show();

            jq("#studio_videoPopupPanel").appendTo("main");

            jq.dropdownToggle({
                switcherSelector: ".menu-list .video-guides .new-label-menu",
                dropdownID: "studio_videoPopupPanel",
                addTop: 5,
                addLeft: 0
            });

            jq("#dropVideoList li a").on("click", function () {
                AjaxPro.timeoutPeriod = 1800000;
                UserVideoGuideUsage.SaveWatchVideo([jq(this).attr("id")]);
            });

            jq("#markVideoRead").on("click", function () {
                var allVideoIds = new Array();
                jq("#dropVideoList li a").each(function () {
                    allVideoIds.push(jq(this).attr("id"));
                });
                AjaxPro.timeoutPeriod = 1800000;
                UserVideoGuideUsage.SaveWatchVideo(allVideoIds);

                jq("#studio_videoPopupPanel").hide();
                jq(".menu-list .video-guides").find(".new-label-menu").hide();

            });
        }
    };
};

jq(document).ready(function() {
    VideoSaver.Init();
})